package com.qianli.cashmama.trade;

import com.alibaba.nacos.spring.context.annotation.config.NacosPropertySource;
import com.alibaba.nacos.spring.context.annotation.config.NacosPropertySources;
import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.autoconfigure.metrics.MeterRegistryCustomizer;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ImportResource;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * Created with IntelliJ IDEA.
 * User: sm
 * Date: 2017/7/20
 * Time: 上午10:30
 */
@SpringBootApplication
@ComponentScan(basePackages = {
        "com.fqgj.common",
        "com.qianli.cashmama.trade"
})
@ImportResource({
        "classpath:app-redis.xml",
        "classpath:amazon-s3-service.xml",
        "classpath:config.xml",
        "classpath*:oss-service.xml",
        "classpath:dubbo-provider.xml"
})
@EnableTransactionManagement
@EnableScheduling
@EnableAsync
@NacosPropertySources({
        @NacosPropertySource(dataId = "dc-trade", autoRefreshed = true),
})
public class TradeApplication {
    public static void main(String[] args) {
        SpringApplication.run(TradeApplication.class, args);
    }

    @Bean
    MeterRegistryCustomizer<MeterRegistry> configurer(@Value("${spring.application.name}") String applicationName) {
        return registry -> registry.config().commonTags("application", applicationName);
    }
}
